<template>
  <div>
    <div v-if="show" class="cus">
      <div class="cus_box">
        <div class="title">
          <span>Abnormal Record</span
          ><i @click="show = false" class="el-icon-close"></i>
        </div>
        <div class="content">
          <el-table :data="tableData" height="250" border style="width: 100%">
            <el-table-column prop="id" label="ID" width="180">
            </el-table-column>
            <el-table-column prop="stime" label="Time" width="180">
            </el-table-column>
            <el-table-column prop="alarm" label="Abnormal Message">
            </el-table-column>
            <el-table-column label="Operations">
              <template slot-scope="scope">
                <el-button @click="del(scope.row)">Delete</el-button>
              </template>
            </el-table-column>
          </el-table>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "Abnormal_record",
  data() {
    return {
      show: false,
      tableData: [],
      row: {}
    };
  },
  mounted() {},
  methods: {
    async getData() {
      const res = await this.apis.alarm_list({
        pageNum: 1,
        pageSize: 100000,
        devId: this.row.deviceNo
      });

      const list = res.rows || [];
      this.tableData = list;
    },
    del(row) {
      this.$confirm("Confirm要Delete吗?", "Hint", {
        confirmButtonText: "Confirm",
        cancelButtonText: "Cancel",
        type: "warning"
      })
        .then(async () => {
          const res = await this.apis.alarm_del({
            id: row.id
          });

          this.$message({
            type: "success",
            message: "DeleteSuccess!"
          });
        })
        .catch(() => {});
    },
    show_fun(row) {
      console.log("我进来了", row);
      this.row = row;
      this.show = true;
      this.getData();
    }
  }
};
</script>

<style scoped lang="scss"></style>
